home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Controls.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  12.4 KB  |  416 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Controls.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __CONTROLS__
  18. #define __CONTROLS__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __QUICKDRAW__
  27. #include <Quickdraw.h>
  28. #endif
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <QuickdrawText.h>                                    */
  31.  
  32. #ifndef __MENUS__
  33. #include <Menus.h>
  34. #endif
  35. /*    #include <Memory.h>                                            */
  36. /*    #include <Events.h>                                            */
  37. /*        #include <OSUtils.h>                                    */
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if GENERATINGPOWERPC
  44. #pragma options align=mac68k
  45. #endif
  46.  
  47. #ifdef __CFM68K__
  48. #pragma lib_export on
  49. #endif
  50.  
  51. #ifndef STRICT_CONTROLS
  52. #define STRICT_CONTROLS 0
  53. #endif
  54.  
  55. enum {
  56.     pushButProc                    = 0,
  57.     checkBoxProc                = 1,
  58.     radioButProc                = 2,
  59.     scrollBarProc                = 16,
  60.     popupMenuProc                = 1008
  61. };
  62.  
  63. /**/
  64. /* Standard System 7 CDEF variant codes for use in control creation API's*/
  65. /**/
  66. enum {
  67.     useWFont                    = 8
  68. };
  69.  
  70. #if OLDROUTINENAMES
  71. enum {
  72.     inLabel                        = 1,
  73.     inMenu                        = 2,
  74.     inTriangle                    = 4,
  75.     inButton                    = 10,
  76.     inCheckBox                    = 11,
  77.     inUpButton                    = 20,
  78.     inDownButton                = 21,
  79.     inPageUp                    = 22,
  80.     inPageDown                    = 23,
  81.     inThumb                        = 129
  82. };
  83.  
  84. #endif
  85. typedef UInt8 ControlPartCode;
  86.  
  87. typedef UInt8 ControlHiliteValue;
  88.  
  89.  
  90. enum {
  91.     kNoHiliteControlPart        = 0,
  92.     kInLabelControlPart            = 1,
  93.     kInMenuControlPart            = 2,
  94.     kInTriangleControlPart        = 4,
  95.     kInButtonControlPart        = 10,
  96.     kInCheckBoxControlPart        = 11,
  97.     kInUpButtonControlPart        = 20,
  98.     kInDownButtonControlPart    = 21,
  99.     kInPageUpControlPart        = 22,
  100.     kInPageDownControlPart        = 23,
  101.     kInIndicatorControlPart        = 129,
  102.     kReservedControlPart        = 254,
  103.     kControlInactiveControlPart    = 255
  104. };
  105.  
  106. /**/
  107. /* System 7 Pop-up menu variants*/
  108. /**/
  109. enum {
  110.     popupFixedWidth                = 1 << 0,
  111.     popupVariableWidth            = 1 << 1,
  112.     popupUseAddResMenu            = 1 << 2,
  113.     popupUseWFont                = 1 << 3
  114. };
  115.  
  116. /**/
  117. /* System 7 Pop-up menu title styles*/
  118. /**/
  119. enum {
  120.     popupTitleBold                = 1 << 8,
  121.     popupTitleItalic            = 1 << 9,
  122.     popupTitleUnderline            = 1 << 10,
  123.     popupTitleOutline            = 1 << 11,
  124.     popupTitleShadow            = 1 << 12,
  125.     popupTitleCondense            = 1 << 13,
  126.     popupTitleExtend            = 1 << 14,
  127.     popupTitleNoStyle            = 1 << 15
  128. };
  129.  
  130. /**/
  131. /* System 7 Pop-up menu label justifications*/
  132. /**/
  133. enum {
  134.     popupTitleLeftJust            = 0x00000000,
  135.     popupTitleCenterJust        = 0x00000001,
  136.     popupTitleRightJust            = 0x000000FF
  137. };
  138.  
  139. /**/
  140. /* Axis constraints for DragGrayRgn call*/
  141. /**/
  142. enum {
  143.     noConstraint                = kNoConstraint,
  144.     hAxisOnly                    = 1,
  145.     vAxisOnly                    = 2
  146. };
  147.  
  148. /**/
  149. /* Messages for the control defproc*/
  150. /**/
  151. typedef SInt16 ControlDefProcMessage;
  152.  
  153.  
  154. enum {
  155.     drawCntl                    = 0,
  156.     testCntl                    = 1,
  157.     calcCRgns                    = 2,
  158.     initCntl                    = 3,
  159.     dispCntl                    = 4,
  160.     posCntl                        = 5,
  161.     thumbCntl                    = 6,
  162.     dragCntl                    = 7,
  163.     autoTrack                    = 8,
  164.     calcCntlRgn                    = 10,
  165.     calcThumbRgn                = 11,
  166.     drawThumbOutline            = 12
  167. };
  168.  
  169. /**/
  170. /* Control color table part codes*/
  171. /**/
  172. enum {
  173.     cFrameColor                    = 0,
  174.     cBodyColor                    = 1,
  175.     cTextColor                    = 2,
  176.     cThumbColor                    = 3
  177. };
  178.  
  179. #if STRICT_CONTROLS
  180. typedef struct OpaqueControlRef *ControlRef;
  181.  
  182. typedef ControlRef ControlHandle;
  183.  
  184. #else
  185. typedef struct ControlRecord ControlRecord, *ControlPtr, **ControlHandle;
  186.  
  187. typedef ControlHandle ControlRef;
  188.  
  189. #endif
  190. /**/
  191. /* Define the main entry point to the standard action proc pointer*/
  192. /**/
  193. typedef pascal long (*ControlDefProcPtr)(short varCode, ControlRef theControl, short message, long param);
  194. typedef pascal void (*ControlActionProcPtr)(ControlRef theControl, short partCode);
  195.  
  196. #if GENERATINGCFM
  197. typedef UniversalProcPtr ControlDefUPP;
  198. typedef UniversalProcPtr ControlActionUPP;
  199. #else
  200. typedef ControlDefProcPtr ControlDefUPP;
  201. typedef ControlActionProcPtr ControlActionUPP;
  202. #endif
  203.  
  204. struct CtlCTab {
  205.     long                            ccSeed;
  206.     short                            ccRider;
  207.     short                            ctSize;
  208.     ColorSpec                        ctTable[4];
  209. };
  210. typedef struct CtlCTab CtlCTab;
  211.  
  212. typedef CtlCTab *CCTabPtr, **CCTabHandle;
  213.  
  214. #if !STRICT_CONTROLS
  215. struct ControlRecord {
  216.     ControlRef                        nextControl;
  217.     WindowRef                        contrlOwner;
  218.     Rect                            contrlRect;
  219.     UInt8                            contrlVis;
  220.     UInt8                            contrlHilite;
  221.     short                            contrlValue;
  222.     short                            contrlMin;
  223.     short                            contrlMax;
  224.     Handle                            contrlDefProc;
  225.     Handle                            contrlData;
  226.     ControlActionUPP                contrlAction;
  227.     long                            contrlRfCon;
  228.     Str255                            contrlTitle;
  229. };
  230. /**/
  231. /* Define private pop-up menu storage (hung off contrlData field in ControlRecord).*/
  232. /**/
  233. struct PopupPrivateData {
  234.     MenuHandle                        mHandle;
  235.     short                            mID;
  236. };
  237. typedef struct PopupPrivateData PopupPrivateData;
  238.  
  239. typedef PopupPrivateData *PopupPrivateDataPtr, **PopupPrivateDataHandle;
  240.  
  241. #endif
  242. struct AuxCtlRec {
  243.     Handle                            acNext;
  244.     ControlRef                        acOwner;
  245.     CCTabHandle                        acCTable;
  246.     short                            acFlags;
  247.     long                            acReserved;
  248.     long                            acRefCon;
  249. };
  250. typedef struct AuxCtlRec AuxCtlRec;
  251.  
  252. typedef AuxCtlRec *AuxCtlPtr, **AuxCtlHandle;
  253.  
  254. /**/
  255. /* Structure used in __TrackControl() - See IM I-332*/
  256. /**/
  257. struct IndicatorDragConstraint {
  258.     Rect                            limitRect;
  259.     Rect                            slopRect;
  260.     DragConstraint                    axis;
  261. };
  262. typedef struct IndicatorDragConstraint IndicatorDragConstraint;
  263.  
  264. typedef IndicatorDragConstraint *IndicatorDragConstraintPtr, **IndicatorDragConstraintHandle;
  265.  
  266. enum {
  267.     uppControlDefProcInfo = kPascalStackBased
  268.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  269.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  270.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ControlRef)))
  271.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  272.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))),
  273.     uppControlActionProcInfo = kPascalStackBased
  274.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ControlRef)))
  275.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  276. };
  277.  
  278. #if GENERATINGCFM
  279. #define NewControlDefProc(userRoutine)        \
  280.         (ControlDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlDefProcInfo, GetCurrentArchitecture())
  281. #define NewControlActionProc(userRoutine)        \
  282.         (ControlActionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlActionProcInfo, GetCurrentArchitecture())
  283. #else
  284. #define NewControlDefProc(userRoutine)        \
  285.         ((ControlDefUPP) (userRoutine))
  286. #define NewControlActionProc(userRoutine)        \
  287.         ((ControlActionUPP) (userRoutine))
  288. #endif
  289.  
  290. #if GENERATINGCFM
  291. #define CallControlDefProc(userRoutine, varCode, theControl, message, param)        \
  292.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlDefProcInfo, (varCode), (theControl), (message), (param))
  293. #define CallControlActionProc(userRoutine, theControl, partCode)        \
  294.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlActionProcInfo, (theControl), (partCode))
  295. #else
  296. #define CallControlDefProc(userRoutine, varCode, theControl, message, param)        \
  297.         (*(userRoutine))((varCode), (theControl), (message), (param))
  298. #define CallControlActionProc(userRoutine, theControl, partCode)        \
  299.         (*(userRoutine))((theControl), (partCode))
  300. #endif
  301.  
  302. extern pascal ControlRef NewControl(WindowRef theWindow, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short value, short min, short max, short procID, long refCon)
  303.  ONEWORDINLINE(0xA954);
  304. extern pascal void SetControlTitle(ControlRef theControl, ConstStr255Param title)
  305.  ONEWORDINLINE(0xA95F);
  306. extern pascal void GetControlTitle(ControlRef theControl, Str255 title)
  307.  ONEWORDINLINE(0xA95E);
  308. extern pascal ControlRef GetNewControl(short controlID, WindowRef owner)
  309.  ONEWORDINLINE(0xA9BE);
  310. extern pascal void DisposeControl(ControlRef theControl)
  311.  ONEWORDINLINE(0xA955);
  312. extern pascal void KillControls(WindowRef theWindow)
  313.  ONEWORDINLINE(0xA956);
  314. extern pascal void HideControl(ControlRef theControl)
  315.  ONEWORDINLINE(0xA958);
  316. extern pascal void ShowControl(ControlRef theControl)
  317.  ONEWORDINLINE(0xA957);
  318. extern pascal void DrawControls(WindowRef theWindow)
  319.  ONEWORDINLINE(0xA969);
  320. extern pascal void Draw1Control(ControlRef theControl)
  321.  ONEWORDINLINE(0xA96D);
  322. extern pascal void HiliteControl(ControlRef theControl, short hiliteState)
  323.  ONEWORDINLINE(0xA95D);
  324. extern pascal void UpdateControls(WindowRef theWindow, RgnHandle updateRgn)
  325.  ONEWORDINLINE(0xA953);
  326. extern pascal void MoveControl(ControlRef theControl, short h, short v)
  327.  ONEWORDINLINE(0xA959);
  328. extern pascal void SizeControl(ControlRef theControl, short w, short h)
  329.  ONEWORDINLINE(0xA95C);
  330. extern pascal void SetControlValue(ControlRef theControl, short theValue)
  331.  ONEWORDINLINE(0xA963);
  332. extern pascal short GetControlValue(ControlRef theControl)
  333.  ONEWORDINLINE(0xA960);
  334. extern pascal void SetControlMinimum(ControlRef theControl, short minValue)
  335.  ONEWORDINLINE(0xA964);
  336. extern pascal short GetControlMinimum(ControlRef theControl)
  337.  ONEWORDINLINE(0xA961);
  338. extern pascal void SetControlMaximum(ControlRef theControl, short maxValue)
  339.  ONEWORDINLINE(0xA965);
  340. extern pascal short GetControlMaximum(ControlRef theControl)
  341.  ONEWORDINLINE(0xA962);
  342. #if !STRICT_CONTROLS
  343. extern pascal Boolean GetAuxiliaryControlRecord(ControlRef theControl, AuxCtlHandle *acHndl)
  344.  ONEWORDINLINE(0xAA44);
  345. #endif
  346. extern pascal void SetControlReference(ControlRef theControl, long data)
  347.  ONEWORDINLINE(0xA95B);
  348. extern pascal long GetControlReference(ControlRef theControl)
  349.  ONEWORDINLINE(0xA95A);
  350. extern pascal void SetControlAction(ControlRef theControl, ControlActionUPP actionProc)
  351.  ONEWORDINLINE(0xA96B);
  352. extern pascal ControlActionUPP GetControlAction(ControlRef theControl)
  353.  ONEWORDINLINE(0xA96A);
  354. extern pascal void DragControl(ControlRef theControl, Point startPt, const Rect *limitRect, const Rect *slopRect, short axis)
  355.  ONEWORDINLINE(0xA967);
  356. extern pascal short TestControl(ControlRef theControl, Point thePt)
  357.  ONEWORDINLINE(0xA966);
  358. extern pascal short FindControl(Point thePoint, WindowRef theWindow, ControlRef *theControl)
  359.  ONEWORDINLINE(0xA96C);
  360. extern pascal void SetControlColor(ControlRef theControl, CCTabHandle newColorTable)
  361.  ONEWORDINLINE(0xAA43);
  362. extern pascal short GetControlVariant(ControlRef theControl)
  363.  ONEWORDINLINE(0xA809);
  364. /*
  365.     When using the TrackControl() call when tracking an indicator, the
  366.     actionProc parameter (type ControlActionUPP) should be replaced by
  367.     a parameter of type DragGrayRgnUPP (defined in Quickdraw.<header>).
  368. */
  369. extern pascal short TrackControl(ControlRef theControl, Point thePoint, ControlActionUPP actionProc)
  370.  ONEWORDINLINE(0xA968);
  371. #if CGLUESUPPORTED
  372. extern void dragcontrol(ControlRef theControl, Point *startPt, const Rect *limitRect, const Rect *slopRect, short axis);
  373. extern ControlRef newcontrol(WindowRef theWindow, const Rect *boundsRect, const char *title, Boolean visible, short value, short min, short max, short procID, long refCon);
  374. extern short findcontrol(Point *thePoint, WindowRef theWindow, ControlRef *theControl);
  375. extern void getcontroltitle(ControlRef theControl, char *title);
  376. extern void setcontroltitle(ControlRef theControl, const char *title);
  377. extern short trackcontrol(ControlRef theControl, Point *thePoint, ControlActionUPP actionProc);
  378. extern short testcontrol(ControlRef theControl, Point *thePt);
  379. #endif
  380. #if OLDROUTINENAMES
  381. #define SetCTitle(theControl, title) SetControlTitle(theControl, title)
  382. #define GetCTitle(theControl, title) GetControlTitle(theControl, title)
  383. #define UpdtControl(theWindow, updateRgn) UpdateControls(theWindow, updateRgn)
  384. #define SetCtlValue(theControl, theValue) SetControlValue(theControl, theValue)
  385. #define GetCtlValue(theControl) GetControlValue(theControl)
  386. #define SetCtlMin(theControl, minValue) SetControlMinimum(theControl, minValue)
  387. #define GetCtlMin(theControl) GetControlMinimum(theControl)
  388. #define SetCtlMax(theControl, maxValue) SetControlMaximum(theControl, maxValue)
  389. #define GetCtlMax(theControl) GetControlMaximum(theControl)
  390. #define GetAuxCtl(theControl, acHndl) GetAuxiliaryControlRecord(theControl, acHndl)
  391. #define SetCRefCon(theControl, data) SetControlReference(theControl, data)
  392. #define GetCRefCon(theControl) GetControlReference(theControl)
  393. #define SetCtlAction(theControl, actionProc) SetControlAction(theControl, actionProc)
  394. #define GetCtlAction(theControl) GetControlAction(theControl)
  395. #define SetCtlColor(theControl, newColorTable) SetControlColor(theControl, newColorTable)
  396. #define GetCVariant(theControl) GetControlVariant(theControl)
  397. #if CGLUESUPPORTED
  398. #define getctitle(theControl, title) getcontroltitle(theControl, title)
  399. #define setctitle(theControl, title) setcontroltitle(theControl, title)
  400. #endif
  401. #endif
  402.  
  403. #ifdef __CFM68K__
  404. #pragma lib_export off
  405. #endif
  406.  
  407. #if GENERATINGPOWERPC
  408. #pragma options align=reset
  409. #endif
  410.  
  411. #ifdef __cplusplus
  412. }
  413. #endif
  414.  
  415. #endif /* __CONTROLS__ */
  416.